namespace CSharpPro._1014;

public class Demo
{
    public static void Sort(double[] a)
    {
        double temp;
        for (int i = 0; i < a.Length - 1; i++)
        {
            for (int j = 0; j < a.Length - i - 1; j++)
            {
                if (a[j] > a[j + 1])
                {
                    temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
    }
    public static void TestSort()
    {
        double[] array = { 5.2, 2.8, 9.1, 1.5, 6.4 };
        
        Console.WriteLine("排序前的数组:");
        PrintArray(array);
        
        Sort(array);
        
        Console.WriteLine("排序后的数组:");
        PrintArray(array);
    }

    public static void PrintArray(double[] array)
    {
        foreach (var item in array)
        {
            Console.Write(item + " ");
        }
        Console.WriteLine();
    }
}